home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / freeWAIS-sf-1.1 / ir / panic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-07  |  2.7 KB  |  129 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE:
  2.    No guarantees or restrictions.  See the readme file for the full standard
  3.    disclaimer.
  4.  
  5.    Morris@think.com
  6. */
  7.  
  8. /* Copyright (c) CNIDR (see ../COPYRIGHT) */
  9.  
  10.  
  11. /* Change log:
  12.  * $Log: panic.c,v $
  13.  * Revision 1.6  1994/08/08  07:32:47  pfeifer
  14.  * Moved wais_log_file_name and waislogfile to cutil.[ch]
  15.  *
  16.  * Revision 1.4  1994/07/22  12:25:20  pfeifer
  17.  * Renamed logfile to waislogfile and log_file_name to wais_log_file_name
  18.  * to avoid clashes when linking with gopher and other systems
  19.  *
  20.  * Revision 1.3  1994/05/20  12:57:00  pfeifer
  21.  * beta
  22.  *
  23.  * Revision 1.2  1994/03/08  21:06:38  pfeifer
  24.  * Patchlevel 04
  25.  *
  26.  * Revision 1.1  1993/02/16  15:05:35  freewais
  27.  * Initial revision
  28.  *
  29.  * Revision 1.10  92/03/07  19:42:30  jonathan
  30.  * ANSIfied arguments.
  31.  * 
  32.  * Revision 1.9  92/02/20  13:58:10  jonathan
  33.  * Removed redundant include of varargs.h.  Removed fprintf for BSD, since
  34.  * we've not got a vprintf.
  35.  * 
  36.  * Revision 1.8  92/02/12  13:38:05  jonathan
  37.  * Added "$Log" so RCS will put the log message in the header
  38.  * 
  39. */
  40.  
  41. /* panic is an error system interface.  On the Mac, it will pop
  42.  * up a little window to explain the problem.
  43.  * On a unix box, it will print out the error and call perror()
  44.  */
  45.  
  46. #include "panic.h"
  47. #include "futil.h"
  48.  
  49. #include <ctype.h> 
  50.  
  51. #ifndef EXIT_FAILURE  /* should be in stdlib */
  52. #define EXIT_FAILURE (-1)
  53. #endif /* ndef EXIT_FAILURE */
  54.  
  55. /*----------------------------------------------------------------------*/
  56.  
  57. static void exitAction _AP((long error));
  58.  
  59. static void
  60. exitAction(error)
  61. long error;
  62. {
  63.   long i;
  64. #ifdef THINK_C
  65.   Debugger();
  66. #else
  67.   for (i = 0; i < 100000; i++)
  68.     ;
  69. #endif
  70. #if 0
  71.     abort();
  72. #else
  73.   exit(-1);
  74. #endif
  75. }
  76.  
  77. /*----------------------------------------------------------------------*/
  78.  
  79. #define PANIC_HEADER "Fatal Error:  "
  80. #define BELL "\007"
  81.  
  82. #ifdef THINK_C /* pop up a dialog box */
  83. #include "CDynamicError.h"
  84. #endif
  85.  
  86. void
  87. #ifdef ANSI_LIKE
  88.   panic(char* format, ...)
  89. #else
  90. panic(va_alist)
  91. va_dcl
  92. #endif
  93.   {
  94.     va_list ap;            /* the variable arguments */
  95. #ifndef ANSI_LIKE
  96.   char *format;
  97.  
  98.   va_start(ap);
  99.   format = va_arg(ap, char *);
  100. #else
  101.   va_start(ap, format);
  102. #endif
  103.  
  104. #ifdef THINK_C            /* pop up a dialog box */
  105.  
  106.   char buffer[1000];        /* hope this is enough space! */
  107.   long i;
  108.   strncpy(buffer,PANIC_HEADER,1000);
  109.   SysBeep(5);
  110.   vsprintf(buffer + strlen(PANIC_HEADER),format,ap);
  111.   for (i = 0L; buffer[i] != '\0'; i++)
  112.     { if (buffer[i] == '\n' || buffer[i] == '\r')
  113.     buffer[i] = ' ';
  114.       }
  115.   gError->PostAlertMessage(buffer);
  116.  
  117. #else
  118.   
  119.   vwaislog(1, -1, format, ap);
  120.   va_end(ap);
  121.  
  122. #endif
  123.  
  124.   exitAction(0);
  125. }
  126.   
  127.  
  128. /*----------------------------------------------------------------------*/
  129.